package com.cs157a.dao;

import java.io.*;
import java.sql.*;
import java.util.*;
import java.math.*;

/**
 * RdiPart Value Object. This class is value object representing database table
 * RdiPart This class is intented to be used together with associated Dao
 * object.
 */

public class RdiPart implements Cloneable, Serializable {

	private static final long serialVersionUID = 20012100301L;
	/**
	 * Persistent Instance variables. This data is directly mapped to the
	 * columns of database table.
	 */
	private String vendor;
	private String PartNumber;
	private String Core;
	private String InHead;
	private String OutHead;
	private String InCon;
	private String OuCon;
	private String TMount;
	private String OilCool;
	private double Price;
	private int Amount;
	private PartType type;

	/**
	 * Constructors. DaoGen generates two constructors by default. The first one
	 * takes no arguments and provides the most simple way to create object
	 * instance. The another one takes one argument, which is the primary key of
	 * the corresponding table.
	 */

	public RdiPart() {

	}

	public RdiPart(String PartNumberIn) {

		this.PartNumber = PartNumberIn;

	}

	/**
	 * Get- and Set-methods for persistent variables. The default behaviour does
	 * not make any checks against malformed data, so these might require some
	 * manual additions.
	 */

	public String getVendor() {
		return this.vendor;
	}

	public void setVendor(String VendorIn) {
		this.vendor = VendorIn;
	}

	public String getPartNumber() {
		return this.PartNumber;
	}

	public void setPartNumber(String PartNumberIn) {
		this.PartNumber = PartNumberIn;
	}

	public String getCore() {
		return this.Core;
	}

	public void setCore(String CoreIn) {
		this.Core = CoreIn;
	}

	public String getInHead() {
		return this.InHead;
	}

	public void setInHead(String InHeadIn) {
		this.InHead = InHeadIn;
	}

	public String getOutHead() {
		return this.OutHead;
	}

	public void setOutHead(String OutHeadIn) {
		this.OutHead = OutHeadIn;
	}

	public String getInCon() {
		return this.InCon;
	}

	public void setInCon(String InConIn) {
		this.InCon = InConIn;
	}

	public String getOuCon() {
		return this.OuCon;
	}

	public void setOuCon(String OuConIn) {
		this.OuCon = OuConIn;
	}

	public String getTMount() {
		return this.TMount;
	}

	public void setTMount(String TMountIn) {
		this.TMount = TMountIn;
	}

	public String getOilCool() {
		return this.OilCool;
	}

	public void setOilCool(String OilCoolIn) {
		this.OilCool = OilCoolIn;
	}

	public double getPrice() {
		return this.Price;
	}

	public void setPrice(double PriceIn) {
		this.Price = PriceIn;
	}

	public int getAmount() {
		return this.Amount;
	}

	public void setAmount(int AmountIn) {
		this.Amount = AmountIn;
	}

	/**
	 * setAll allows to set all persistent variables in one method call. This is
	 * useful, when all data is available and it is needed to set the initial
	 * state of this object. Note that this method will directly modify instance
	 * variales, without going trough the individual set-methods.
	 */

	public void setAll(String PartNumberIn, String CoreIn, String InHeadIn,
			String OutHeadIn, String InConIn, String OuConIn, String TMountIn,
			String OilCoolIn, double PriceIn, int AmountIn) {
		this.PartNumber = PartNumberIn;
		this.Core = CoreIn;
		this.InHead = InHeadIn;
		this.OutHead = OutHeadIn;
		this.InCon = InConIn;
		this.OuCon = OuConIn;
		this.TMount = TMountIn;
		this.OilCool = OilCoolIn;
		this.Price = PriceIn;
		this.Amount = AmountIn;
	}

	/**
	 * hasEqualMapping-method will compare two RdiPart instances and return true
	 * if they contain same values in all persistent instance variables. If
	 * hasEqualMapping returns true, it does not mean the objects are the same
	 * instance. However it does mean that in that moment, they are mapped to
	 * the same row in database.
	 */
	public boolean hasEqualMapping(RdiPart valueObject) {

		if (this.PartNumber == null) {
			if (valueObject.getPartNumber() != null)
				return (false);
		} else if (!this.PartNumber.equals(valueObject.getPartNumber())) {
			return (false);
		}
		if (this.Core == null) {
			if (valueObject.getCore() != null)
				return (false);
		} else if (!this.Core.equals(valueObject.getCore())) {
			return (false);
		}
		if (this.InHead == null) {
			if (valueObject.getInHead() != null)
				return (false);
		} else if (!this.InHead.equals(valueObject.getInHead())) {
			return (false);
		}
		if (this.OutHead == null) {
			if (valueObject.getOutHead() != null)
				return (false);
		} else if (!this.OutHead.equals(valueObject.getOutHead())) {
			return (false);
		}
		if (this.InCon == null) {
			if (valueObject.getInCon() != null)
				return (false);
		} else if (!this.InCon.equals(valueObject.getInCon())) {
			return (false);
		}
		if (this.OuCon == null) {
			if (valueObject.getOuCon() != null)
				return (false);
		} else if (!this.OuCon.equals(valueObject.getOuCon())) {
			return (false);
		}
		if (this.TMount == null) {
			if (valueObject.getTMount() != null)
				return (false);
		} else if (!this.TMount.equals(valueObject.getTMount())) {
			return (false);
		}
		if (this.OilCool == null) {
			if (valueObject.getOilCool() != null)
				return (false);
		} else if (!this.OilCool.equals(valueObject.getOilCool())) {
			return (false);
		}
		if (valueObject.getPrice() != this.Price) {
			return (false);
		}
		if (valueObject.getAmount() != this.Amount) {
			return (false);
		}

		return true;
	}

	public PartType getType() {
		return type;
	}

	public void setType(PartType type) {
		this.type = type;
	}

	/**
	 * toString will return String object representing the state of this
	 * valueObject. This is useful during application development, and possibly
	 * when application is writing object states in textlog.
	 */
	public String toString() {
		StringBuffer out = new StringBuffer("");
		// out.append("\nclass RdiPart, mapping to table RdiPart\n");
		out.append("Persistent attributes: \n");
		out.append("Part Vendor = " + this.vendor + "\n");
		out.append("PartNumber = " + this.PartNumber + "\n");
		out.append("Core = " + this.Core + "\n");
		out.append("InHead = " + this.InHead + "\n");
		out.append("OutHead = " + this.OutHead + "\n");
		out.append("InCon = " + this.InCon + "\n");
		out.append("OuCon = " + this.OuCon + "\n");
		out.append("TMount = " + this.TMount + "\n");
		out.append("OilCool = " + this.OilCool + "\n");
		out.append("Price = " + this.Price + "\n");
		out.append("Amount = " + this.Amount + "\n");
		out.append("Type = " + this.type + "\n");
		return out.toString();
	}

	/**
	 * Clone will return identical deep copy of this valueObject. Note, that
	 * this method is different than the clone() which is defined in
	 * java.lang.Object. Here, the retuned cloned object will also have all its
	 * attributes cloned.
	 */
	public Object clone() {
		RdiPart cloned = new RdiPart();

		if (this.PartNumber != null)
			cloned.setPartNumber(new String(this.PartNumber));
		if (this.Core != null)
			cloned.setCore(new String(this.Core));
		if (this.InHead != null)
			cloned.setInHead(new String(this.InHead));
		if (this.OutHead != null)
			cloned.setOutHead(new String(this.OutHead));
		if (this.InCon != null)
			cloned.setInCon(new String(this.InCon));
		if (this.OuCon != null)
			cloned.setOuCon(new String(this.OuCon));
		if (this.TMount != null)
			cloned.setTMount(new String(this.TMount));
		if (this.OilCool != null)
			cloned.setOilCool(new String(this.OilCool));
		cloned.setPrice(this.Price);
		cloned.setAmount(this.Amount);
		cloned.setVendor(this.vendor);
		return cloned;
	}

}
